inherited fmVizit: TfmVizit
  Left = 505
  Top = 194
  Width = 984
  Height = 739
  Caption = #1042#1080#1079#1080#1090#1099
  Constraints.MinHeight = 739
  Constraints.MinWidth = 984
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  inherited sbBottom: TStatusBar
    Top = 674
    Width = 968
  end
  inherited Panel1: TPanel
    Width = 968
    Visible = False
    inherited BitBtn1: TBitBtn
      Left = 806
    end
    inherited BitBtn2: TBitBtn
      Left = 894
    end
  end
  object dbgVizit: TcxGrid [2]
    Left = 0
    Top = 89
    Width = 968
    Height = 585
    Align = alClient
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentFont = False
    TabOrder = 2
    TabStop = False
    LookAndFeel.Kind = lfStandard
    object tvVizit: TcxGridDBTableView
      NavigatorButtons.ConfirmDelete = False
      NavigatorButtons.First.Visible = True
      NavigatorButtons.PriorPage.Visible = True
      NavigatorButtons.Prior.Visible = True
      NavigatorButtons.Next.Visible = True
      NavigatorButtons.NextPage.Visible = True
      NavigatorButtons.Last.Visible = True
      NavigatorButtons.Insert.Visible = False
      NavigatorButtons.Append.Visible = False
      NavigatorButtons.Delete.Visible = False
      NavigatorButtons.Edit.Visible = False
      NavigatorButtons.Post.Visible = False
      NavigatorButtons.Cancel.Visible = False
      NavigatorButtons.Refresh.Visible = False
      NavigatorButtons.SaveBookmark.Visible = False
      NavigatorButtons.GotoBookmark.Visible = False
      NavigatorButtons.Filter.Visible = False
      OnCellClick = tvVizitCellClick
      DataController.DataSource = dsVizit
      DataController.Summary.DefaultGroupSummaryItems = <>
      DataController.Summary.FooterSummaryItems = <>
      DataController.Summary.SummaryGroups = <>
      OptionsBehavior.CellHints = True
      OptionsBehavior.ImmediateEditor = False
      OptionsBehavior.IncSearch = True
      OptionsData.CancelOnExit = False
      OptionsData.Deleting = False
      OptionsData.DeletingConfirmation = False
      OptionsData.Inserting = False
      OptionsView.CellEndEllipsis = True
      OptionsView.NavigatorOffset = 10
      OptionsView.NoDataToDisplayInfoText = '<'#1053#1077#1090' '#1076#1072#1085#1085#1099#1093'>'
      OptionsView.CellAutoHeight = True
      OptionsView.CellTextMaxLineCount = 1
      OptionsView.ColumnAutoWidth = True
      OptionsView.Indicator = True
      Preview.Visible = True
      object tvVizitPVID: TcxGridDBColumn
        Caption = #8470' '#1089#1082#1074#1079#1085
        DataBinding.FieldName = 'PVID'
        Options.Editing = False
        Width = 20
      end
      object tvVizitFIO: TcxGridDBColumn
        Caption = #1060#1048#1054
        DataBinding.FieldName = 'FIO'
        Options.Editing = False
        Width = 20
      end
      object tvVizitSTATUS: TcxGridDBColumn
        Caption = #1057#1090#1072#1090#1091#1089
        DataBinding.FieldName = 'STATUS'
        Options.Editing = False
        Width = 20
      end
      object tvVizitPODRAZD: TcxGridDBColumn
        Caption = #1054#1089#1085'. '#1087#1086#1076#1088#1072#1079#1076'.'
        DataBinding.FieldName = 'PODRAZD'
        Options.Editing = False
        Width = 31
      end
      object tvVizitPODRID: TcxGridDBColumn
        DataBinding.FieldName = 'PODRID'
      end
      object tvVizitPVTIME_IN: TcxGridDBColumn
        Caption = #1042#1093#1086#1076
        DataBinding.FieldName = 'PVTIME_IN'
        PropertiesClassName = 'TcxDateEditProperties'
        Properties.ImmediatePost = True
        Properties.Kind = ckDateTime
        Options.Editing = False
        Width = 20
      end
      object tvVizitPVTIME_OUT: TcxGridDBColumn
        Caption = #1042#1099#1093#1086#1076
        DataBinding.FieldName = 'PVTIME_OUT'
        PropertiesClassName = 'TcxDateEditProperties'
        Properties.ImmediatePost = True
        Properties.Kind = ckDateTime
        Options.Editing = False
        Width = 20
      end
      object tvVizitH: TcxGridDBColumn
        Caption = #1050#1086#1083'. '#1095#1072#1089'.'
        DataBinding.FieldName = 'H'
        Options.Editing = False
        Width = 20
      end
      object tvVizitPP_IN: TcxGridDBColumn
        Caption = #1040#1074#1090#1086#1088' '#1074#1093#1086#1076#1072
        DataBinding.FieldName = 'PP_IN'
        Options.Editing = False
        Width = 28
      end
      object tvVizitPP_OUT: TcxGridDBColumn
        Caption = #1040#1074#1090#1086#1088' '#1074#1099#1093#1086#1076#1072
        DataBinding.FieldName = 'PP_OUT'
        Options.Editing = False
        Width = 32
      end
      object tvVizitSCAN_IN: TcxGridDBColumn
        Caption = #1058#1080#1087' '#1074#1093#1086#1076#1072
        DataBinding.FieldName = 'SCAN_IN'
        Options.Editing = False
        Width = 24
      end
      object tvVizitSCAN_OUT: TcxGridDBColumn
        Caption = #1058#1080#1087' '#1074#1099#1093#1086#1076#1072
        DataBinding.FieldName = 'SCAN_OUT'
        Options.Editing = False
        Width = 26
      end
      object tvVizitPVPRIZNAK_IN: TcxGridDBColumn
        Caption = #1055#1088#1080#1079#1085#1072#1082' '#1074#1093'.'
        DataBinding.FieldName = 'PVPRIZNAK_IN'
        PropertiesClassName = 'TcxCheckBoxProperties'
        Properties.NullStyle = nssUnchecked
        Properties.ReadOnly = True
        Properties.ValueChecked = 1
        Properties.ValueUnchecked = 0
        Options.Editing = False
        Width = 29
      end
      object tvVizitPVPRIZNAK_OUT: TcxGridDBColumn
        Caption = #1055#1088#1080#1079#1085#1072#1082' '#1074#1099#1093'.'
        DataBinding.FieldName = 'PVPRIZNAK_OUT'
        PropertiesClassName = 'TcxCheckBoxProperties'
        Properties.NullStyle = nssUnchecked
        Properties.ReadOnly = True
        Properties.ValueChecked = 1
        Properties.ValueUnchecked = 0
        Options.Editing = False
        Width = 36
      end
      object tvVizitUSER_EXTRA: TcxGridDBColumn
        Caption = #1056#1072#1079#1088#1077#1096#1077#1085#1080#1077' '#1085#1072' '#1074#1093#1086#1076' '#1086#1090
        DataBinding.FieldName = 'USER_EXTRA'
        Options.Editing = False
        Width = 64
      end
      object tvVizitPRICHINA: TcxGridDBColumn
        Caption = #1040#1074#1090#1086#1084'. '#1087#1088#1080#1095#1080#1085#1072' '#1079#1072#1087#1088#1077#1090#1072
        DataBinding.FieldName = 'PRICHINA'
        Options.Editing = False
        Width = 92
      end
      object tvVizitNOTE: TcxGridDBColumn
        Caption = #1050#1086#1084#1084#1077#1085#1090'. '#1082' '#1088#1072#1079#1088#1077#1096'.'
        DataBinding.FieldName = 'NOTE'
        Options.Editing = False
        Width = 108
      end
    end
    object cxGridLevel3: TcxGridLevel
      GridView = tvVizit
    end
  end
  object Panel2: TPanel [3]
    Left = 0
    Top = 45
    Width = 968
    Height = 44
    Align = alTop
    TabOrder = 3
    object Label10: TLabel
      Left = 7
      Top = 9
      Width = 37
      Height = 16
      Caption = #1044#1072#1090#1072'*'
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clGray
      Font.Height = -13
      Font.Name = 'Tahoma'
      Font.Style = []
      ParentFont = False
    end
    object Label1: TLabel
      Left = 298
      Top = 4
      Width = 404
      Height = 33
      Caption = 
        '* '#1077#1089#1083#1080' '#1076#1072#1090#1072' '#1085#1077' '#1091#1082#1072#1079#1072#1085#1072', '#1090#1086' '#1074#1099#1074#1086#1076#1103#1090#1089#1103' '#1076#1072#1085#1085#1099#1077' '#1079#1072' '#1087#1086#1089#1083#1077#1076#1085#1080#1077' 5 '#1076#1085#1077#1081',' +
        #13#10#1084#1072#1082#1089#1080#1084#1072#1083#1100#1085#1072#1103' '#1075#1083#1091#1073#1080#1085#1072' '#1087#1088#1086#1089#1084#1086#1090#1088#1072' - 45 '#1076#1085#1077#1081#13#10
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clGray
      Font.Height = -13
      Font.Name = 'Tahoma'
      Font.Style = []
      ParentFont = False
    end
    object eVizitDate: TcxButtonEdit
      Tag = 11
      Left = 50
      Top = 6
      ParentFont = False
      Properties.Buttons = <
        item
          Glyph.Data = {
            F6000000424DF600000000000000760000002800000010000000100000000100
            0400000000008000000000000000000000001000000000000000000000000000
            8000008000000080800080000000800080008080000080808000C0C0C0000000
            FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00FFFFFFFFFFFF
            FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
            FFFFFFFFFFF0FFFFFFFFFFFFFF000FFFFFFFFFFFF00000FFFFFFFFFF0000000F
            FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
            FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}
        end>
      Properties.MaxLength = 0
      Properties.ReadOnly = True
      Properties.OnButtonClick = ePaymentDatePropertiesButtonClick
      Properties.OnChange = eVizitDatePropertiesChange
      Style.Font.Charset = DEFAULT_CHARSET
      Style.Font.Color = clWindowText
      Style.Font.Height = -13
      Style.Font.Name = 'Tahoma'
      Style.Font.Style = [fsBold]
      Style.LookAndFeel.SkinName = ''
      Style.Shadow = False
      Style.IsFontAssigned = True
      StyleDisabled.LookAndFeel.SkinName = ''
      StyleFocused.LookAndFeel.SkinName = ''
      StyleHot.LookAndFeel.SkinName = ''
      TabOrder = 0
      Width = 242
    end
  end
  object dsVizit: TDataSource
    DataSet = qVizit
    Left = 48
    Top = 168
  end
  object qVizit: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    BufferChunks = 500
    CachedUpdates = True
    DataSource = dlgDS
    SQL.Strings = (
      
        'SELECT PV.*, (COALESCE(P.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P.PNAME,'#39 +
        ' '#39')||'#39' '#39'||COALESCE(P.PPATRONYMIC,'#39' '#39')) AS fio,'
      
        '    (COALESCE(P_IN.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P_IN.PNAME,'#39' '#39')' +
        ') AS PP_IN,'
      
        '    (COALESCE(P_OUT.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P_OUT.PNAME,'#39' ' +
        #39')) AS PP_OUT,'
      '    CASE PV.PVSCANRESULT_IN'
      '    WHEN 1 THEN '#39#1054#1090#1087#1077#1095'. '#1080' '#1082#1072#1088#1090#1072#39
      '    WHEN 2 THEN '#39#1050#1072#1088#1090#1072#39
      '    WHEN 3 THEN '#39#1054#1090#1087#1077#1095#1072#1090#1086#1082#39
      '    WHEN 4 THEN '#39#1056#1091#1095#1085#1086#1081#39
      '    END AS scan_in,'
      '    CASE PV.PVSCANRESULT_OUT'
      '    WHEN 1 THEN '#39#1054#1090#1087#1077#1095'. '#1080' '#1082#1072#1088#1090#1072#39
      '    WHEN 2 THEN '#39#1050#1072#1088#1090#1072#39
      '    WHEN 3 THEN '#39#1054#1090#1087#1077#1095#1072#1090#1086#1082#39
      '    WHEN 4 THEN '#39#1056#1091#1095#1085#1086#1081#39
      '    END AS scan_out,'
      
        '    COALESCE(P_ex.PLASTNAME||'#39' '#39'||P_ex.PNAME, te.USERENTER) AS u' +
        'ser_extra,'
      
        '    IIF(PS.SDID IN (1246,1248), SD.SDNAME, COALESCE(dol.sdname, ' +
        #39#1042#1080#1079#1080#1090#1077#1088#39') ) AS status, podr.sdname AS podrazd,'
      
        '    DATEDIFF(HOUR FROM pv.pvtime_in TO COALESCE(pv.pvtime_out, C' +
        'URRENT_TIMESTAMP)) AS h,'
      '    sel.prichina,'
      '    te.NOTE'
      'FROM P_VIZIT PV'
      'LEFT OUTER JOIN USERS U_IN ON U_IN.USNAME = PV.PVUSERENTER'
      'LEFT OUTER JOIN PEOPLE P_IN ON P_IN.PID = U_IN.PID'
      'LEFT OUTER JOIN USERS U_OUT ON U_OUT.USNAME = PV.PVUSEREDIT'
      'LEFT OUTER JOIN PEOPLE P_OUT ON P_OUT.PID = U_OUT.PID'
      'LEFT OUTER JOIN PEOPLE P_ex ON P_ex.PID = PV.PVPIDEXTRA'
      'LEFT OUTER JOIN PEOPLE P ON P.PID = PV.PID'
      'LEFT OUTER JOIN P_STATUS PS ON PS.PID = P.PID'
      'LEFT OUTER JOIN SYS_DIC SD ON SD.SDID = PS.SDID'
      'LEFT OUTER JOIN ('
      'SELECT APU.PID, sd.SDNAME'
      'FROM DETI_PODRAZD_SC DP'
      'INNER JOIN SPEC_COND SC ON SC.SCID = DP.SCID'
      'INNER JOIN AGR_POLUCH_USLUG APU ON APU.AGID = SC.AGID'
      'INNER JOIN SYS_DIC SD ON SD.SDID = DP.SDID'
      'WHERE  CURRENT_DATE BETWEEN CAST(dp.DPDATEIN AS DATE)'
      '    AND COALESCE(CAST(dp.DPDATEOUT AS DATE), CURRENT_DATE)'
      '    AND DP.DPTYPE = 1 AND SC.SCISDELETE IS NULL'
      ') as podr on podr.pid = PV.PID'
      'LEFT OUTER JOIN'
      '('
      'SELECT SA.PVID, LIST(SD.SDNAME, '#39', '#39') AS prichina'
      'FROM SECURITY_ACESSDENIED SA'
      'INNER JOIN SYS_DIC SD ON SD.SDID = SA.SDID'
      'GROUP BY 1'
      ') AS sel ON sel.pvid = PV.PVID'
      'LEFT OUTER JOIN KPP_TEMP_ENTER te ON te.PVID = pv.PVID'
      'LEFT OUTER JOIN'
      '('
      'SELECT d.PID, sd.SDNAME'
      'FROM DOLJNOST_PEOPLE d'
      'INNER JOIN DOLJNOST D1 ON d1.DOLID = d.DOLID'
      'INNER JOIN SYS_DIC SD ON SD.SDID = d1.SDID'
      'WHERE d.DOLISDELETE IS NULL'
      
        'AND CURRENT_DATE BETWEEN D.DOLDATEBEGIN AND COALESCE(d.DOLDATEEN' +
        'D, CURRENT_DATE)'
      ') AS dol ON DOL.pid = pv.PID'
      
        'WHERE CAST(PV.PVTIME_IN AS DATE) BETWEEN :data_begin AND :data_e' +
        'nd'
      'order by 16 asc , 4 desc')
    UpdateObject = IBUpdateSQL1
    GeneratorField.Field = 'PVID'
    GeneratorField.Generator = 'GEN_P_VIZIT_ID'
    Left = 16
    Top = 168
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'data_begin'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data_end'
        ParamType = ptUnknown
      end>
    object qVizitPVID: TIntegerField
      FieldName = 'PVID'
      Origin = '"P_VIZIT"."PVID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object qVizitPID: TIntegerField
      FieldName = 'PID'
      Origin = '"P_VIZIT"."PID"'
    end
    object qVizitPVTARGET: TIntegerField
      FieldName = 'PVTARGET'
      Origin = '"P_VIZIT"."PVTARGET"'
    end
    object qVizitPVTIME_IN: TDateTimeField
      FieldName = 'PVTIME_IN'
      Origin = '"P_VIZIT"."PVTIME_IN"'
    end
    object qVizitPVTIME_OUT: TDateTimeField
      FieldName = 'PVTIME_OUT'
      Origin = '"P_VIZIT"."PVTIME_OUT"'
    end
    object qVizitPVPRIZNAK_IN: TIntegerField
      FieldName = 'PVPRIZNAK_IN'
      Origin = '"P_VIZIT"."PVPRIZNAK_IN"'
    end
    object qVizitPVPRIZNAK_OUT: TIntegerField
      FieldName = 'PVPRIZNAK_OUT'
      Origin = '"P_VIZIT"."PVPRIZNAK_OUT"'
    end
    object qVizitPVNOTE: TIBStringField
      FieldName = 'PVNOTE'
      Origin = '"P_VIZIT"."PVNOTE"'
      Size = 255
    end
    object qVizitPVUSERENTER: TIBStringField
      FieldName = 'PVUSERENTER'
      Origin = '"P_VIZIT"."PVUSERENTER"'
      Size = 40
    end
    object qVizitPVTIMEENTER: TDateTimeField
      FieldName = 'PVTIMEENTER'
      Origin = '"P_VIZIT"."PVTIMEENTER"'
    end
    object qVizitPVUSEREDIT: TIBStringField
      FieldName = 'PVUSEREDIT'
      Origin = '"P_VIZIT"."PVUSEREDIT"'
      Size = 40
    end
    object qVizitPVTIMEEDIT: TDateTimeField
      FieldName = 'PVTIMEEDIT'
      Origin = '"P_VIZIT"."PVTIMEEDIT"'
    end
    object qVizitFIO: TIBStringField
      FieldName = 'FIO'
      ProviderFlags = []
      Size = 769
    end
    object qVizitPVSCANRESULT_IN: TIntegerField
      FieldName = 'PVSCANRESULT_IN'
      Origin = '"P_VIZIT"."PVSCANRESULT_IN"'
    end
    object qVizitPVSCANRESULT_OUT: TIntegerField
      FieldName = 'PVSCANRESULT_OUT'
      Origin = '"P_VIZIT"."PVSCANRESULT_OUT"'
    end
    object qVizitPVPIDEXTRA: TIntegerField
      FieldName = 'PVPIDEXTRA'
      Origin = '"P_VIZIT"."PVPIDEXTRA"'
    end
    object qVizitPP_IN: TIBStringField
      FieldName = 'PP_IN'
      ProviderFlags = []
      Size = 511
    end
    object qVizitPP_OUT: TIBStringField
      FieldName = 'PP_OUT'
      ProviderFlags = []
      Size = 511
    end
    object qVizitSCAN_IN: TIBStringField
      FieldName = 'SCAN_IN'
      ProviderFlags = []
      FixedChar = True
      Size = 14
    end
    object qVizitSCAN_OUT: TIBStringField
      FieldName = 'SCAN_OUT'
      ProviderFlags = []
      FixedChar = True
      Size = 14
    end
    object qVizitUSER_EXTRA: TIBStringField
      FieldName = 'USER_EXTRA'
      ProviderFlags = []
      Size = 511
    end
    object qVizitSTATUS: TIBStringField
      FieldName = 'STATUS'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
    object qVizitPODRAZD: TIBStringField
      FieldName = 'PODRAZD'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
    object qVizitH: TLargeintField
      FieldName = 'H'
      ProviderFlags = []
    end
    object qVizitPRICHINA: TMemoField
      FieldName = 'PRICHINA'
      ProviderFlags = []
      BlobType = ftMemo
      Size = 8
    end
    object qVizitNOTE: TIBStringField
      FieldName = 'NOTE'
      Origin = '"KPP_TEMP_ENTER"."NOTE"'
      Size = 255
    end
    object qVizitPODRID: TIntegerField
      DisplayLabel = 'ID '#1087#1086#1076#1088#1072#1079#1076
      FieldName = 'PODRID'
      Origin = '"P_VIZIT"."PODRID"'
    end
  end
  object IBUpdateSQL1: TIBUpdateSQL
    RefreshSQL.Strings = (
      'Select '
      '  PVID,'
      '  PID,'
      '  PVTARGET,'
      '  PVTIME_IN,'
      '  PVTIME_OUT,'
      '  PVPRIZNAK_IN,'
      '  PVPRIZNAK_OUT,'
      '  PVNOTE,'
      '  PVUSERENTER,'
      '  PVTIMEENTER,'
      '  PVUSEREDIT,'
      '  PVTIMEEDIT'
      'from P_VIZIT '
      'where'
      '  PVID = :PVID')
    ModifySQL.Strings = (
      'update P_VIZIT'
      'set'
      '  PID = :PID,'
      '  PVID = :PVID,'
      '  PVNOTE = :PVNOTE,'
      '  PVPRIZNAK_IN = :PVPRIZNAK_IN,'
      '  PVPRIZNAK_OUT = :PVPRIZNAK_OUT,'
      '  PVTARGET = :PVTARGET,'
      '  PVTIME_IN = :PVTIME_IN,'
      '  PVTIME_OUT = :PVTIME_OUT,'
      '  PVTIMEEDIT = :PVTIMEEDIT,'
      '  PVTIMEENTER = :PVTIMEENTER,'
      '  PVUSEREDIT = :PVUSEREDIT,'
      '  PVUSERENTER = :PVUSERENTER'
      'where'
      '  PVID = :OLD_PVID')
    InsertSQL.Strings = (
      'insert into P_VIZIT'
      
        '  (PID, PVID, PVNOTE, PVPRIZNAK_IN, PVPRIZNAK_OUT, PVTARGET, PVT' +
        'IME_IN, '
      '   PVTIME_OUT, PVTIMEEDIT, PVTIMEENTER, PVUSEREDIT, PVUSERENTER)'
      'values'
      
        '  (:PID, :PVID, :PVNOTE, :PVPRIZNAK_IN, :PVPRIZNAK_OUT, :PVTARGE' +
        'T, :PVTIME_IN, '
      
        '   :PVTIME_OUT, :PVTIMEEDIT, :PVTIMEENTER, :PVUSEREDIT, :PVUSERE' +
        'NTER)')
    DeleteSQL.Strings = (
      'delete from P_VIZIT'
      'where'
      '  PVID = :OLD_PVID')
    Left = 16
    Top = 200
  end
end
